<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateYouzanAuthorizersTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('youzan_authorizers', function(Blueprint $table)
		{
			$table->increments('id');
			$table->integer('youzan_store_id')->nullable()->comment('有赞店铺的id');
			$table->string('access_token')->nullable()->comment('用于调用 API 的 access_token，有效7天；access_token失效前可通过refresh_token刷新获取新的access_token，有效期仍是7天');
			$table->string('expires_in')->nullable()->comment('access_token 的有效时长，单位：秒（过期时间：7天）');
			$table->string('refresh_token')->nullable()->comment('用于延长 access_token 有效时间的刷新令牌（过期时间：28 天），在刷新后access_token会返回新的refresh_token');
			$table->string('scope')->nullable()->comment('access_token 最终的访问范围');
			$table->string('token_type')->nullable()->comment('令牌类型');
			$table->string('youzan_store_name')->nullable()->comment('有赞店铺的名称');
			$table->string('youzan_store_logo')->nullable()->comment('有赞店铺的logo');
			$table->string('youzan_store_intro')->nullable()->comment('有赞店铺信息介绍');
			$table->dateTime('expired_at')->default('2000-01-01 00:00:00')->comment('access_token 实际过期时间，access_token写入/更新时改变');
			$table->timestamps();
		});
	}


	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('youzan_authorizers');
	}

}
